
define(['QUnit', 'app/list'], function(QUnit, List){

	var run = function(){


		QUnit.module('List');

		QUnit.test('设置和获取测试', function(assert){
			var theList = new List();
			var firstAdd = 23, secondAdd = 50;

			theList.push(firstAdd);
			theList.push(secondAdd);

			assert.equal(theList.get(0), firstAdd, '相等');
			assert.equal(theList.get(1), secondAdd, '相等');
		});

		QUnit.test('删除测试', function (assert) {

			var theList = new List;
			theList.push(23);
			theList.push(34);
			theList.push(89);

			theList.deleteByIndex(2);

			assert.equal(theList.getLength(), 2, '删除后的数目');
		});

		QUnit.test('测试合并', function(assert){
			var aList = new  List;
			aList.push('a');
			aList.push('b');
			aList.push('c');

			var bList = new List;
			bList.push('d');
			bList.push('e');

			var merged = aList.merge(bList, true);

			assert.equal(merged.getLength(), aList.getLength() +  bList.getLength(), '合并后的数目');

			assert.ok(
				(function(){
					for(var i = 0; i < merged; ++i){
						if( i < aList.length &&  ! merged.get(i) === aList.get(i) ){
							return false;
						}

						if( i >= aList.length && ! merged.get(i) === bList.get(i - aList.length) ){
							return false;
						}
					}

					return true;
				})()
				, '测试合并后的元素是否正常');
		});

	};

	return {
		run: run
	};

});